//PITCH PROGRAM
//CLASS: PLAYERPANEL
//		- panel that shows players cards
//BY: ALEX TRACY
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
public class PlayerPanel extends JPanel
{
	//players cards if the player is the player is the human player playing show cards
	//otherwise don't
	private BufferedImage[] cards = new BufferedImage[6];
	private Player player;
	boolean horizontal;

	
	private int cardSpacing = 30;
	private int selected = -1;
	private int defaultY = 20;
	private int played = -1;

	public PlayerPanel(Player p,boolean h)
	{
		player = p;
		horizontal = h;
	}//End Constructor
	
	//if player is horizontal draw them horizontal
	//otherwise draw them vertical
	//draw cards a cardspacing apart
	public void paintComponent(Graphics g)
	{
		super.paintComponent(g);
		player.initPanel();
		if (horizontal == true)
		{
			for (int i = 0 ; i < cards.length ; i++)
			{
				g.drawImage(player.getCardImage(i),i*cardSpacing,getCardY(i),null);
			}	
		
		}
		else
		{
			for (int i = 0 ; i < cards.length ; i++)
			{
				g.drawImage(player.getCardImage(i),0,i*20,null);
			}	
		}
	}//End paintComponent
	
	//rotates images if the are verical
	public BufferedImage rotate(BufferedImage img, int angle) 
	{  
	    int w = img.getWidth();  
		int h = img.getHeight();  
		BufferedImage dimg = new BufferedImage(w, h, img.getType());  
		Graphics2D g = dimg.createGraphics();  
		g.rotate(Math.toRadians(angle), w/2, h/2);  
		g.drawImage(img, null, 0, 0);  
		return dimg;  
	}//End rotate  
	
	//set selected card
	public void setSelected(int c)
    {
		selected = c;
	}//End setSelected
	 
	//get selected card
	public int getSelected()
    {
		return selected;
    }//End getSelected
	
	//get cards y
	public int getCardY(int c)
    {
		if (c == getSelected())
	   		return 15;
	   	else
	   		return defaultY;
    }//returns cards y
	
	//getCard that is played
    public int getPlayed()
    {
    	return played;	  
    }//End getPlayed
    
    //set played to i
	public void setPlayed(int i)
    {
		played = i;
	}//End setPlayed
	 
	//return the spacing for the cards
	public int getSpacing()
    {
		return cardSpacing;
	}//End getSpacing


}//PlayPanel